<%@ page import="java.util.Map" %>
<%--
  Created by IntelliJ IDEA.
  User: camhoang
  Date: 7/19/11
  Time: 1:11 PM
  To change this template use File | Settings | File Templates.
--%>
<%@include file="include.jsp"%> 

<%
   pageTitle = "Administration";
   configurationTile = "Configure Pages";
%>
<%@include file="header.jsp"%>

      <h1>Add Page</h1>
      <form:form commandName="newPage">
         <table border="0" cellpadding="3" cellspacing="0" width="50%">
            <tr>
               <td>Page URL: </td>
               <td><form:input path="url"/></td>
            </tr>
            <tr>
               <td>Page Type: </td>
               <td><form:select path="type">
                  <%
                     Map<String, String> classifiedClasses = (Map<String, String>) request.getAttribute("classifiedClasses");
                     if (classifiedClasses != null) {
                        for (Object key : classifiedClasses.keySet()) {
                  %>
                           <form:option value="<%=key%>" label="<%=classifiedClasses.get(key)%>"/>
                  <%
                        }
                     }
                  %>
               </form:select></td>
            </tr>
            <tr>
               <td colspan="2">
                  <input type="submit" value="Add Page"/>
               </td>
            </tr>
         </table>
      </form:form>
      <c:if test="${not empty status}">
         <span style="color:red"><b>${status}</b></span>
      </c:if>
      <br/>

      <h1>Configured Pages</h1>
      <table border="1" cellpadding="3" cellspacing="0" width="100%">
         <tr>
            <th>No</th>
            <th>Page URL</th>
            <th>Page type</th>
         </tr>
         <% int count = 0; %>
         <c:forEach items="${pageList}" var="page">
             <tr>
                <td><a href="<c:url value='/administration/page.jhtml?pageId=${page.id}'/>"><%= ++count %></a></td>
                <td><a href="<c:url value='/administration/page.jhtml?pageId=${page.id}'/>">${page.url}</a></td>
                <c:set var="pageTypeAsString">${page.type}</c:set>
                <td>${classifiedClasses[pageTypeAsString]}</td>
             </tr>
         </c:forEach>
      </table>
      <br/>
<%@include file="footer.jsp"%>